<template>
  <a-button type="primary" @click="newClassifyModal = true">添加新分类</a-button>
  <ClassifyTable class="table"
                 :classifies="classifies"
                 @reload="getAllClassify" />
  <NewClassify :visible="newClassifyModal"
               @close="newClassifyModal = false"
               @reload="getAllClassify" />
</template>

<script setup>
import ClassifyTable from "../../../components/admin/blog/classify/ClassifyTable.vue";
import {onMounted, ref} from "vue";
import {apiGet} from "../../../fentch";
import {message} from "ant-design-vue";
import NewClassify from "../../../components/admin/blog/classify/NewClassify.vue";

const newClassifyModal = ref(false)

const classifies = ref([])

// 获取分类数据
const getAllClassify = () => {
  apiGet( '/classify').then(res => {
    if (res.data.code === 0) {
      classifies.value = res.data.data;
      return
    }
    message.error(res.data.message)
  })
}

onMounted(() => {
  getAllClassify()
})
</script>

<style scoped>
.table {
  margin-top: 20px;
}
</style>